#include "guish.hpp"
#ifndef SHELL_HPP
#define SHELL_HPP
#include "Environment.hpp"

class Shell
{
public:
	Shell(ClientConnection *connection);
	~Shell();
	
	void initialize();
	ClientConnection *getClientConnection();
	ShellState *getState();
	
	void runLoginScript(int jobid, int width, int height);
	void runCommand(int jobid, string cmd, int termWidth, int termHeight);
	
	void finishJob(int jobid, PseudoTerminal *pty, int status, ShellState *finalState);
	Job *findJob(int id);
	
	void doExit();
	
protected:
	ShellState *currentState;
	
	ClientConnection *connection;
	
	map<int, Job*> jobs;
	
	void updatePrompt();
	string lastReportedPrompt;
};

extern Shell *shell;

#endif
